﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KandaAlpha.Domain.Model.Entities;
using KandaAlpha.Domain.Repository;

namespace KandaAlpha.UI.Mvc.Tests
{
    public class CustomerRepository : GenericRepository<Customer>, ICustomerRepository
    {

        private List<Customer> _customers;

        public CustomerRepository()
        {
            _customers = new List<Customer>();
            _customers.Add(
                new Customer()
                {
                    FirstName = "Keith",
                    LastName = "Patton",
                    ID = 1,
                   
                }
            );
            _customers.Add(
                new Customer()
                {
                    FirstName = "Annabel",
                    LastName = "Patton",
                    ID = 2,
                }
            );
        }

        public override Customer  Load(System.Linq.Expressions.Expression<Func<Customer,bool>> whereCondition)
        {
            return GetQuery().Where(whereCondition).FirstOrDefault();
        }

        public override IQueryable<Customer> GetQuery()
        {
            return _customers.AsQueryable();
        }

        public override List<Customer> GetAll()
        {
            return this.GetQuery().ToList();
        }

        public Customer GetBestCustomer()
        {
            return this.GetQuery().Where(c => c.FirstName == "Keith" && c.LastName == "Patton").FirstOrDefault();
        }

    }
}
